package com.example.demo.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.example.demo.pojo.String2LongVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Shanks
 * @date 2020-12-08
 */
@Slf4j
@Api(value = "DemoController", tags = {"小样"})
@RestController
public class DemoController {

    /**
     * JSON传参时, 若VO类中某个属性是Long类型, 但是入参时该属性传String型数值的, 后端也是可以正常解析!!
     *
     * 入参:
     * {
     *     "id": "123456789123456789",
     *     "userId": "2",
     *     "name": "Shanks"
     * }
     *
     * 出参:
     * {
     *     "code": 0,
     *     "data": {
     *         "id": 123456789123456789,
     *         "userId": "2",
     *         "name": "Shanks"
     *     },
     *     "msg": "执行成功"
     * }
     */
    @PostMapping("/demo/string2Long")
    @ApiOperation(value = "日期", notes = "日期")
    public R<String2LongVO> string2Long(@RequestBody String2LongVO vo) {
        return R.ok(vo);
    }
}